<?php


namespace Module\ScheduleManager\Admin\Controller;


use Illuminate\Routing\Controller;
use ModStart\Admin\Concern\HasAdminQuickCRUD;
use ModStart\Admin\Layout\AdminCRUDBuilder;
use ModStart\Grid\GridFilter;
use ModStart\Support\Concern\HasFields;
use Module\Vendor\Provider\Schedule\RunStatus;

class ScheduleRunController extends Controller
{
    use HasAdminQuickCRUD;

    protected function crud(AdminCRUDBuilder $builder)
    {
        $builder
            ->init('schedule_run')
            ->field(function ($builder) {
                /** @var HasFields $builder */
                $builder->id('id', 'ID');
                $builder->display('created_at', '创建时间');
                $builder->display('name', '名称');
                $builder->display('startTime', '开始时间');
                $builder->display('endTime', '结束时间');
                $builder->type('status', '状态')->type(RunStatus::class);
                $builder->display('result', '返回结果');
            })
            ->gridFilter(function (GridFilter $filter) {
                $filter->eq('status', '状态')->radio(RunStatus::class);
            })
            ->title('任务调度')
            ->canDelete(false)->canAdd(false)->canEdit(false)->canShow(false);
    }
}
